﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Billing.Utilities;
using System.Drawing.Printing;
using System.Data;

namespace Billing.Windows
{
    /// <summary>
    /// Interaction logic for CakeBalance.xaml
    /// </summary>
    public partial class DataRemainderPopup : Window
    {
        Color cursorEnterColor = Colors.Violet;
        Color cursorLeaveColor = Color.FromArgb(Convert.ToByte("FF", 16), Convert.ToByte("65", 16), Convert.ToByte("65", 16), Convert.ToByte("65", 16));

        public DataRemainderPopup()
        {
            try
            {
                InitializeComponent();

                //Expenses
                
                lblExpenseAmount.Content = Database.GetExpenseTotalForToday();
                
                //Sodexho & Credit Card
                DataTable dt = Database.GetAmounts();
                if (dt != null && dt.Rows.Count > 0)
                {
                    lblSodexhoAmount.Content = dt.Rows[0][0].ToString();
                    lblCreditCardAmount.Content = dt.Rows[0][1].ToString();
                }

                //Advances
                lblAdvanceAmount.Content = Database.GetTotalDebitTransactionsAddedToday(1);
            }
            catch (Exception) { }
        }

        private void Window_KeyUp(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.Key == Key.Escape)
                {
                    this.Close();
                }
                else if (e.Key == Key.P && chkExpense.IsChecked.Value && chkCreditCard.IsChecked.Value && chkSodexho.IsChecked.Value && chkAdvance.IsChecked.Value && chkLeaves.IsChecked.Value && chkOT.IsChecked.Value)
                {
                    this.DialogResult = true;
                    this.Close();
                }
                else if (e.Key == Key.Y)
                {
                    if (chkLeaves.IsChecked.Value)
                    {
                        chkOT.IsChecked = true;
                    }
                    else if (chkAdvance.IsChecked.Value)
                    {
                        chkLeaves.IsChecked = true;
                    }
                    else if (chkSodexho.IsChecked.Value)
                    {
                        chkAdvance.IsChecked = true;
                    }
                    else if (chkCreditCard.IsChecked.Value)
                    {
                        chkSodexho.IsChecked = true;
                    }
                    else if (chkExpense.IsChecked.Value)
                    {
                        chkCreditCard.IsChecked = true;
                    }
                    else
                    {
                        chkExpense.IsChecked = true;
                    }
                }
            }
            catch (Exception) { }
        }
    }
}
